<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/default/easyui.css"></link>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/themes/icon.css"></link>
	<link rel="stylesheet" type="text/css" href="js/jquery-easyui-1.5/demo/demo.css"></link>
	<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/jquery.min.js"></script>
	<script language="JavaScript"  type="text/javascript" src="js/jquery-easyui-1.5/jquery.easyui.min.js"></script>
	<script type="text/javascript">
	
	
	$(document).ready(  
			  function(){
				  var role_id = $("#role_id").val();
				  var url = "loadTree?role_id="+role_id;
				  $.get(url, function(data){
					  var msg = $.parseJSON(data);
					  	 $("#tree").tree("loadData", msg);
					 
					});
					   
			  });
	
	 /*<![CDATA[*/ 
	
	function getChecked(){
		var nodes = $('#tree').tree('getChecked');
		var s = '';
		for(var i=0; i<nodes.length; i++){
			var flag = $('#tree').tree('isLeaf',nodes[i].target);
			if(flag)
			{
				s += nodes[i].id+",";
				
			}
			
		}
		if(s=='')
		{
			alert("请选择");
		}else
		{
			var role_id = $("#role_id").val();
			var url = "add_AuthorityList?id="+role_id+"&authorityList="+s; 
			$.get(url, function(data){
				 
				  	 alert(data);
				 
				});
			
		}
		
	}
	 /*]]>*/  
	</script>
</head>
<body>
	
			<ul class="easyui-tree" id="tree" data-options="checkbox:true">			
			</ul>
			
			<br/>
			<a href="#" class="easyui-linkbutton" onclick="getChecked()">提交</a>
			<input  id="role_id" type="hidden" th:value="${id}" />
		
</body>
</html>